// CppUnit-Tutorial
// file: Fraction.h
#ifndef FRACTION_H
#define FRACTION_H

#include <iostream>

using namespace std;

// some helper functions (actually don't belong here)
// calculates the greatest common factor (for reducing)
unsigned int gcf (unsigned int, unsigned int);
// calculates the least common denominator (for expanding)
unsigned int lcd (unsigned int, unsigned int);

// definition of an exception-class
class DivisionByZeroException
{
};

// simple definition of a fraction-class
class CFraction
{
	public:
		// constructor
    CFraction (int = 0, int = 1) throw (DivisionByZeroException);

		// copy-constructor and assignment-operator
    CFraction (const CFraction&);
    CFraction& operator= (const CFraction&);

		// comparing operators
		bool operator== (const CFraction&) const;
		bool operator!= (const CFraction&) const;

		// arithmetic operators
		friend CFraction operator+ (const CFraction&, const CFraction&);
		friend CFraction operator- (const CFraction&, const CFraction&);

		// output on stdout
		friend ostream& operator<< (ostream&, const CFraction&);

	private:
		// method for reducing
		void reduce (void);

		// variables for saving the numerator and denominator
		int numerator, denominator;
};

#endif
